import http from "@/utils/request";

//封装项目的请求
/*  商品相关的请求  */


// 新增商品分类
function addRequest(name,coverImage,desc, parent){
    return http({
     method: "post",
     url: "/api/v1/admin/productcategory",
     data: {name,coverImage,desc, parent },
    })
 }

// 商品分类列表
function prolistRequest(per,page,name){
    return http({
     method: "get",
     url: "/api/v1/admin/productcategory",
     parmas: {per,page,name},
    })
 }

// 商品分类单删
function proDelRequest(id){
    return http({
     method: "delete",
     url: "/api/v1/admin/productcategory/"+id,
     data: {},
    })
 }

// 商品分类修改
function xgRequest(id,name,coverImage,desc, parent ){
    return http({
     method: "put",
     url: "/api/v1/admin/productcategory/"+id,
     data: {name,coverImage,desc, parent },
    })
 }

/*---------------- ----------------   商品函数     ---------------  ---------------*/ 
// 商品列表
function listRequest(per,page,name,category){
    return http({
     method: "get",
     url: "/api/v1/admin/product",
     params: {per,page,name,category},
    })
 }

 // 新增商品
function sendRequest(name,coverImage,desc,content,views,price,category,onSale,amount){
    return http({
     method: "post",
     url: "/api/v1/admin/product",
     data:{name,coverImage,desc,content,views,price,category,onSale,amount},
    })
 }

 // 商品单删
function deleRequest(id){
    return http({
        method: "delete",
        url: "/api/v1/admin/product/"+id,
        data: {},
    })
 }



// 商品修改
function xglistRequest(id,name,coverImage,desc,views,price,category,onSale,amount){
    return http({
        method: "put",
        url: "/api/v1/admin/product/"+id,
        data: {name,coverImage,desc,views,price,category,onSale,amount},
    })
 }

 /*---------------- ----------------   评论函数     ---------------  ---------------*/ 

 // 评论列表
function commentRequest(per,page,product){
    return http({
     method: "get",
     url: "/api/v1/admin/productcomment",
     params: {per,page,product},
    })
 }

 // 删除评论
function commentDelRequest(id){
    return http({
     method: "delete",
     url: "/api/v1/admin/productcomment/"+id,
     params: {},
    })
 }



 export {addRequest,prolistRequest,proDelRequest,xgRequest ,listRequest, xglistRequest,sendRequest,deleRequest,commentRequest,commentDelRequest}